var statisticCtrl  = new XFApp.client();

XFApp.client.prototype.statistic = {
    successCode : "10000",
    page : null,
	chartItemFlag2:false,
	chartItemFlag3:false,
	statisticChar:null,
	urlItems:{
		loadStatisticInfoURL:basePath+"/statistic/queryStatisticInfo",
		loadStatisticChartInfoURL:basePath+"/statistic/queryStatisticChartInfo",
		amtTopURL : basePath+"/chart/orderMap/amtTop",
        qtyTopURL : basePath+"/chart/orderMap/qtyTop",
        queryAmtTop : basePath+"/chart/goods/amtTop",
        queryQtyTop : basePath+"/chart/goods/qtyTop"
		
	},
	loadStatisticInfo : function(){
		var _this = this;
		 $.ajax({
	            url: _this.urlItems.loadStatisticInfoURL,
	            type: 'post',
	            dataType: 'json',
	            success: function (result) {
	            	_this.showNum("total_amount",result.totalAmount,0);
	            	_this.showNum("total_count",result.orderCount,0);
	            }
		 });
	},
	/**
	 * 
	 * @param id
	 * @param num 显示的数据
	 * @param decimals 小数点位数
	 */
	showNum : function(id,num,decimals){
		var options = {
			useEasing : true,
			useGrouping : true,
			separator : ',', 
			decimal : '.', 
			prefix : '', 
			suffix : ''
		};
		var numDiv = new CountUp(id, 0, num, decimals, 3, options);
		numDiv.start();
		},
	loadStatisticChartInfo : function(){
		var _this = this;
		var params = {};
		if(typeof(statisticCharInfo) != 'undefined'){
			_this.statisticChar = statisticCharInfo;
			params = {
					lastMonth : statisticCharInfo[statisticCharInfo.length-1].monthTime
			}
		}
		 $.ajax({
	            url: _this.urlItems.loadStatisticChartInfoURL,
	            type: 'post',
	            dataType: 'json',
	            data:params,
	            success: function (result) {
	            	if(result instanceof Array){
	            		_this.statisticChar = result;
	            	}else{
	            		//替换最后一个为当前月份数据
	            		_this.statisticChar[_this.statisticChar.length-1] = result;
	            	}
	            	_this.loadOrderAmountChart(3);
	            }
		 });
	},
	
	/**
	 *	type:1:半年,2:1年,3:3年,4:5年 
	 */
	loadOrderAmountChart : function(type){
		var _this = this;
		//初始化echarts实例
	    var myChart = echarts.init($("#orderAmountChart")[0]);
		var timeData = [];
		var showData = [];
		var timeDataObj = {};
		for(var index = 0;index < _this.statisticChar.length; index++){
			if(type == 1 || type == 2){
				timeData.push(_this.statisticChar[index].monthTime);
				showData.push(_this.statisticChar[index].totalAmount);
			}else if(type == 4){
				var time = _this.statisticChar[index].monthTime.split("-")[0];
				if(timeDataObj.hasOwnProperty(time)){
					var data = parseFloat(timeDataObj[time]) + _this.statisticChar[index].totalAmount;
					timeDataObj[time] = data.toFixed(2);
				}else{
					var data = _this.statisticChar[index].totalAmount;
					timeDataObj[time] = data.toFixed(2);
				}
			}else if(type == 3){
				var monthRange = parseInt(_this.statisticChar[index].monthTime.split("-")[1]);
				var year = _this.statisticChar[index].monthTime.split("-")[0];
				var key = year;
				if(monthRange/6 <= 1){
					key+="-01~06";
				}else{
					key+="-07~12";
				}
				if(timeDataObj.hasOwnProperty(key)){
					var data = parseFloat(timeDataObj[key]) + _this.statisticChar[index].totalAmount;
					timeDataObj[key] = data.toFixed(2);
				}else{
					var data = _this.statisticChar[index].totalAmount;
					timeDataObj[key] = data.toFixed(2);
				}
			}
		}
		if(type == 3 || type == 4){
			for(var key in timeDataObj){
				timeData.push(key);
				showData.push(timeDataObj[key]);
			}
		}
		timeData = timeData.map(function (str) {
		        return str;
		});
		
		var zoomParam = {start:0,end:100};
		if(type == 2){
			zoomParam.start=80;
			zoomParam.end=100;
		}else if(type == 1){
			zoomParam.start=91;
			zoomParam.end=100;
		}
		
	    option = {
	        title: {
	            text: '出口贸易额',
	            x: 'center'
	        },
	        tooltip: {
	            trigger: 'axis',
	            formatter: function (params) {
	                return params[0].name + '<br/>'
	                    + params[0].seriesName + ' : ' + params[0].value + ' (USD)<br/>';
	            },
	            axisPointer: {
	                animation: false
	            }
	        },
	      /*  legend: {
	            data:['金额'],
	            x: 'left'
	        },*/
	        dataZoom: [
	                   {   // 这个dataZoom组件，默认控制x轴。
	                       type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
	                       start: zoomParam.start,      // 左边在 n% 的位置。
	                       end: zoomParam.end         // 右边在n% 的位置。
	                   }
	               ],
	        grid: [{
	            left: 50,
	            right: 50,
	            height: '75%'
	        }],
	        xAxis : [
	            {
	                type : 'category',
	                boundaryGap : false,
	                splitLine:{show: false},
	                axisLine: {onZero: true},
	                data: timeData
	            }
	        ],
	        yAxis : [
	            {
	                name : '金额(USD)',
	                type : 'value',
	            }
	        ],
	        series : [
	            {
	                name:'金额',
	                type:'line',
	                symbolSize: 8,
	                hoverAnimation: false,
	                data:showData
	            }
	        ]
		    };
		    // 使用刚指定的配置项和数据显示图表。
		    myChart.setOption(option);
	},
	
	/**
	 *	type:1:半年,2:1年,3:3年,4:5年 
	 */
	loadTransPackageChart : function(type){
		//初始化echarts实例
	    var myChart = echarts.init($("#transCountChart")[0]);
		var timeData = [];
		var showData = [];
		var timeDataObj = {};
		for(var index = 0;index < _this.statisticChar.length; index++){
			if(type == 1 || type == 2){
				timeData.push(_this.statisticChar[index].monthTime);
				showData.push(_this.statisticChar[index].packageCount);
			}else if(type == 4){
				var time = _this.statisticChar[index].monthTime.split("-")[0];
				if(timeDataObj.hasOwnProperty(time)){
					var data = timeDataObj[time] + _this.statisticChar[index].packageCount;
					timeDataObj[time] = data;
				}else{
					var data = _this.statisticChar[index].packageCount;
					timeDataObj[time] = data;
				}
			}else if(type == 3){
				var monthRange = parseInt(_this.statisticChar[index].monthTime.split("-")[1]);
				var year = _this.statisticChar[index].monthTime.split("-")[0];
				var key = year;
				if(monthRange/6 <= 1){
					key+="-01~06";
				}else{
					key+="-07~12";
				}
				if(timeDataObj.hasOwnProperty(key)){
					var data = timeDataObj[key] + _this.statisticChar[index].packageCount;
					timeDataObj[key] = data;
				}else{
					var data = _this.statisticChar[index].packageCount;
					timeDataObj[key] = data;
				}
			}
		}
		if(type == 3 || type == 4){
			for(var key in timeDataObj){
				timeData.push(key);
				showData.push(timeDataObj[key]);
			}
		}
		timeData = timeData.map(function (str) {
		        return str;
		});
		
		var zoomParam = {start:0,end:100};
		if(type == 2){
			zoomParam.start=80;
			zoomParam.end=100;
		}else if(type == 1){
			zoomParam.start=91;
			zoomParam.end=100;
		}
		
	    option = {
	        title: {
	            text: '出口包裹数',
	            x: 'center'
	        },
	        tooltip: {
	            trigger: 'axis',
	            formatter: function (params) {
	                return params[0].name + '<br/>'
	                    + params[0].seriesName + ' : ' + params[0].value + ' (个)<br/>';
	            },
	            axisPointer: {
	                animation: false
	            }
	        },
	        legend: {
	            data:['个数'],
	            x: 'left'
	        },
	        dataZoom: [
	                   {   // 这个dataZoom组件，默认控制x轴。
	                       type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
	                       start: zoomParam.start,      // 左边在 n% 的位置。
	                       end: zoomParam.end         // 右边在n% 的位置。
	                   }
	               ],
	        grid: [{
	            left: 50,
	            right: 50,
	            height: '75%'
	        }],
	        xAxis : [
	            {
	                type : 'category',
	                boundaryGap : false,
	                splitLine:{show: false},
	                axisLine: {onZero: true},
	                data: timeData
	            }
	        ],
	        yAxis : [
	            {
	                name : '数量(个)',
	                type : 'value',
	            }
	        ],
	        series : [
	            {
	                name:'数量',
	                type:'line',
	                symbolSize: 8,
	                hoverAnimation: false,
	                data:showData
	            }
	        ]
		    };
		    // 使用刚指定的配置项和数据显示图表。
		    myChart.setOption(option);
	},
	
	/**
	 *	type:1:半年,2:1年,3:3年,4:5年 
	 */
	loadOrderCustomerChart : function(type){
		//初始化echarts实例
		var _this = this;
	    var myChart = echarts.init($("#orderCustomerChart")[0]);
		var timeData = [];
		var showData1 = [];
		var showData2 = [];
		var timeDataObj1 = {};
		var timeDataObj2 = {};
		for(var index = 0;index < _this.statisticChar.length; index++){
			if(type == 1 || type == 2){
				timeData.push(_this.statisticChar[index].monthTime);
				showData1.push(_this.statisticChar[index].orderCount);
				showData2.push(_this.statisticChar[index].customerAmount);
			}else if(type == 4){
				var time = _this.statisticChar[index].monthTime.split("-")[0];
				if(timeDataObj1.hasOwnProperty(time)){
					timeDataObj1[time] = timeDataObj1[time] + _this.statisticChar[index].orderCount;
				}else{
					timeDataObj1[time] = _this.statisticChar[index].orderCount;
				}
				if(timeDataObj2.hasOwnProperty(time)){
					var data = parseFloat(timeDataObj2[time]) + _this.statisticChar[index].customerAmount;
					timeDataObj2[time] = data.toFixed(2);
				}else{
					var data = _this.statisticChar[index].customerAmount;
					timeDataObj2[time] = data.toFixed(2);
				}
			}else if(type == 3){
				var monthRange = parseInt(_this.statisticChar[index].monthTime.split("-")[1]);
				var year = _this.statisticChar[index].monthTime.split("-")[0];
				var key = year;
				if(monthRange/6 <= 1){
					key+="-01~06";
				}else{
					key+="-07~12";
				}
				if(timeDataObj1.hasOwnProperty(key)){
					timeDataObj1[key] = timeDataObj1[key] + _this.statisticChar[index].orderCount;
				}else{
					timeDataObj1[key] = _this.statisticChar[index].orderCount;
				}
				
				if(timeDataObj2.hasOwnProperty(key)){
					var data = parseFloat(timeDataObj2[key]) + _this.statisticChar[index].customerAmount;
					timeDataObj2[key] = data.toFixed(2);
				}else{
					var data = _this.statisticChar[index].customerAmount;
					timeDataObj2[key] = data.toFixed(2);
				}
			}
		}
		if(type == 3 || type == 4){
			for(var key in timeDataObj1){
				timeData.push(key);
				showData1.push(timeDataObj1[key]);
			}
			for(var key in timeDataObj2){
				showData2.push(timeDataObj2[key]);
			}
		}
		timeData = timeData.map(function (str) {
		        return str;
		});
		
		var zoomParam = {start:0,end:100};
		if(type == 2){
			zoomParam.start=80;
			zoomParam.end=100;
		}else if(type == 1){
			zoomParam.start=91;
			zoomParam.end=100;
		}
		
	    option = {
	        title: {
	            text: '订单量及客单价',
	            x: 'center'
	        },
	        tooltip: {
	            trigger: 'axis',
	            /*formatter: function (params) {
	            	
	                return params[0].name + '<br/>'
	                    + params[0].seriesName + ' : ' + params[0].value + ' (USD)<br/>';
	            },*/
	            axisPointer: {
	                animation: false
	            }
	        },
	        legend: {
	            data:['订单量','客单价'],
	            x: 'left'
	        },
	        dataZoom: [
	                   {   // 这个dataZoom组件，默认控制x轴。
	                       type: 'slider', // 这个 dataZoom 组件是 slider 型 dataZoom 组件
	                       start: zoomParam.start,      // 左边在 n% 的位置。
	                       end: zoomParam.end         // 右边在n% 的位置。
	                   }
	               ],
	        grid: [{
	            left: 50,
	            right: 50,
	            height: '75%'
	        }],
	        xAxis : [
	            {
	                type : 'category',
	                boundaryGap : false,
	                axisLine: {onZero: true},
	                splitLine:{show: false},
	                data: timeData
	            }
	        ],
	        yAxis : [
				{
				    name : '个/USD',
				    type : 'value',
				}
	        ],
	        series : [
				{
				    name:'订单量',
				    type:'line',
				    symbolSize: 8,
				    hoverAnimation: false,
				    data:showData1
				},
	            {
	                name:'客单价',
	                type:'line',
	                symbolSize: 8,
	                hoverAnimation: false,
	                data:showData2
	            }
	        ]
		    };
		    // 使用刚指定的配置项和数据显示图表。
		    myChart.setOption(option);
	},
	bindEvent:function(){
		var _this = this;
		$("#time_switch1>a").on("click",function(){
			if(!$(this).hasClass("active")){
				$("#time_switch1>a").removeClass("active");
				$(this).addClass("active");
				var type = $(this).index()+1;
				_this.loadOrderAmountChart(type);
			}
		});
		$("#time_switch2>a").on("click",function(){
			if(!$(this).hasClass("active")){
				$("#time_switch2>a").removeClass("active");
				$(this).addClass("active");
				var type = $(this).index()+1;
				_this.loadTransPackageChart(type);
			}
		});
		$("#time_switch3>a").on("click",function(){
			if(!$(this).hasClass("active")){
				$("#time_switch3>a").removeClass("active");
				$(this).addClass("active");
				var type = $(this).index()+1;
				_this.loadOrderCustomerChart(type);
			}
		});
		$("#chart_type_switch>a").on("click",function(){
			var index = $(this).index()+1;
			if(!$(this).hasClass("active")){
				$("#chart_type_switch>a").removeClass("active");
				$(this).addClass("active");
				$("div[id^='tabChart']").css("display","none");
				$("#tabChart"+index).css("display","");
				if(index == 2 && _this.chartItemFlag2 == false){
					_this.chartItemFlag2 = true;
					_this.loadTransPackageChart(3);
				}
				if(index == 3 && _this.chartItemFlag3 == false){
					_this.chartItemFlag3 = true;
					_this.loadOrderCustomerChart(3);
				}
			}
		});
		 _this.loadMap();
	},
	
	loop:0,
    option : {
        backgroundColor: 'rgba(128, 128, 128, 0)', //#1a283f
        color: ['gold', 'aqua', 'lime'],
        title: {text: '地域维度（出口地区排名）',x: 'center',textStyle: {color: '#fff'}},
        tooltip: {
            trigger: 'item',
            formatter: '{b}'
        },

        dataRange: {
            show: true,
            x: 'left',
            y: 'center',
            min: 0,
            max: 100,
            calculable: true,
            color: ['#ff3333', 'orange', 'yellow', 'lime', 'aqua'],
            textStyle: {
                color: '#fff'
            }
        },
        series: [
            {
                name: '中俄',
                type: 'map',
                roam: false,
                hoverable: true,
                mapType: '中俄',
                roam: true,
                itemStyle: {
                    normal: {
                        borderColor: 'rgba(100,149,237,0.3)', //#3D5F99
                        borderWidth: 0.3,
                        areaStyle: {
                            color: '#004882'    //#121C2D
                        },
                        label: {show: false}
                    },
                    emphasis:{
                    	color: 'rgba(0, 72, 130, 0)'   //#121C2D
                    }
                },
                data: [],
                markLine: {
                    smooth: true,
                    symbol: ['none', 'circle'],
                    symbolSize: 1,
                    itemStyle: {
                        normal: {
                            color: '#fff',
                            opacity: 0.3,
                            borderWidth: 1,
                            borderColor: 'rgba(89, 123, 179, 0.3)'
                        }
                    },
                    data: []
                },
                geoCoord: {},
                // 自定义名称
                nameMap: {
                    'Afghanistan': '阿富汗',
                    'Angola': '安哥拉',
                    'Albania': '阿尔巴尼亚',
                    'United Arab Emirates': '阿联酋',
                    'Argentina': '阿根廷',
                    'Armenia': '亚美尼亚',
                    'French Southern and Antarctic Lands': '法属南半球和南极领地',
                    'Australia': '澳大利亚',
                    'Austria': '乌苏里斯克',
                    'Azerbaijan': '阿塞拜疆',
                    'Burundi': '布隆迪',
                    'Belgium': '比利时',
                    'Benin': '贝宁',
                    'Burkina Faso': '布基纳法索',
                    'Bangladesh': '孟加拉国',
                    'Bulgaria': '保加利亚',
                    'The Bahamas': '巴哈马',
                    'Bosnia and Herzegovina': '波斯尼亚和黑塞哥维那',
                    'Belarus': '白俄罗斯',
                    'Belize': '伯利兹',
                    'Bermuda': '百慕大',
                    'Bolivia': '玻利维亚',
                    'Brazil': '巴西',
                    'Brunei': '文莱',
                    'Bhutan': '不丹',
                    'Botswana': '博茨瓦纳',
                    'Central African Republic': '中非共和国',
                    'Canada': '加拿大',
                    'Switzerland': '瑞士',
                    'Chile': '智利',
                    'China': '中国',
                    'Ivory Coast': '象牙海岸',
                    'Cameroon': '喀麦隆',
                    'Democratic Republic of the Congo': '刚果民主共和国',
                    'Republic of the Congo': '刚果共和国',
                    'Colombia': '哥伦比亚',
                    'Costa Rica': '哥斯达黎加',
                    'Cuba': '古巴',
                    'Northern Cyprus': '北塞浦路斯',
                    'Cyprus': '塞浦路斯',
                    'Czech Republic': '捷克共和国',
                    'Germany': '德国',
                    'Djibouti': '吉布提',
                    'Denmark': '丹麦',
                    'Dominican Republic': '多明尼加共和国',
                    'Algeria': '阿尔及利亚',
                    'Ecuador': '厄瓜多尔',
                    'Egypt': '埃及',
                    'Eritrea': '厄立特里亚',
                    'Spain': '西班牙',
                    'Estonia': '爱沙尼亚',
                    'Ethiopia': '埃塞俄比亚',
                    'Finland': '芬兰',
                    'Fiji': '斐',
                    'Falkland Islands': '福克兰群岛',
                    'France': '法国',
                    'Gabon': '加蓬',
                    'United Kingdom': '英国',
                    'Georgia': '格鲁吉亚',
                    'Ghana': '加纳',
                    'Guinea': '几内亚',
                    'Gambia': '冈比亚',
                    'Guinea Bissau': '几内亚比绍',
                    'Equatorial Guinea': '赤道几内亚',
                    'Greece': '希腊',
                    'Greenland': '格陵兰',
                    'Guatemala': '危地马拉',
                    'French Guiana': '法属圭亚那',
                    'Guyana': '圭亚那',
                    'Honduras': '洪都拉斯',
                    'Croatia': '克罗地亚',
                    'Haiti': '海地',
                    'Hungary': '匈牙利',
                    'Indonesia': '印尼',
                    'India': '印度',
                    'Ireland': '新西伯利亚',
                    'Iran': '伊朗',
                    'Iraq': '伊拉克',
                    'Iceland': '冰岛',
                    'Israel': '以色列',
                    'Italy': '意大利',
                    'Jamaica': '牙买加',
                    'Jordan': '约旦',
                    'Japan': '日本',
                    'Kazakhstan': '哈萨克斯坦',
                    'Kenya': '肯尼亚',
                    'Kyrgyzstan': '吉尔吉斯斯坦',
                    'Cambodia': '柬埔寨',
                    'South Korea': '韩国',
                    'Kosovo': '科索沃',
                    'Kuwait': '科威特',
                    'Laos': '老挝',
                    'Lebanon': '黎巴嫩',
                    'Liberia': '利比里亚',
                    'Libya': '利比亚',
                    'Sri Lanka': '斯里兰卡',
                    'Lesotho': '莱索托',
                    'Lithuania': '立陶宛',
                    'Luxembourg': '卢森堡',
                    'Latvia': '拉脱维亚',
                    'Morocco': '摩洛哥',
                    'Moldova': '摩尔多瓦',
                    'Madagascar': '马达加斯加',
                    'Mexico': '墨西哥',
                    'Macedonia': '马其顿',
                    'Mali': '马里',
                    'Myanmar': '缅甸',
                    'Montenegro': '黑山',
                    'Mongolia': '蒙古',
                    'Mozambique': '莫桑比克',
                    'Mauritania': '毛里塔尼亚',
                    'Malawi': '马拉维',
                    'Malaysia': '马来西亚',
                    'Namibia': '纳米比亚',
                    'New Caledonia': '新喀里多尼亚',
                    'Niger': '尼日尔',
                    'Nigeria': '尼日利亚',
                    'Nicaragua': '尼加拉瓜',
                    'Netherlands': '荷兰',
                    'Norway': '挪威',
                    'Nepal': '尼泊尔',
                    'New Zealand': '新西兰',
                    'Oman': '阿曼',
                    'Pakistan': '巴基斯坦',
                    'Panama': '巴拿马',
                    'Peru': '秘鲁',
                    'Philippines': '菲律宾',
                    'Papua New Guinea': '巴布亚新几内亚',
                    'Poland': '波兰',
                    'Puerto Rico': '波多黎各',
                    'North Korea': '北朝鲜',
                    'Portugal': '葡萄牙',
                    'Paraguay': '巴拉圭',
                    'Qatar': '卡塔尔',
                    'Romania': '罗马尼亚',
                    'Russia': '俄罗斯',
                    'Rwanda': '卢旺达',
                    'Western Sahara': '西撒哈拉',
                    'Saudi Arabia': '沙特阿拉伯',
                    'Sudan': '苏丹',
                    'South Sudan': '南苏丹',
                    'Senegal': '塞内加尔',
                    'Solomon Islands': '所罗门群岛',
                    'Sierra Leone': '塞拉利昂',
                    'El Salvador': '萨尔瓦多',
                    'Somaliland': '索马里兰',
                    'Somalia': '索马里',
                    'Republic of Serbia': '塞尔维亚共和国',
                    'Suriname': '苏里南',
                    'Slovakia': '斯洛伐克',
                    'Slovenia': '斯洛文尼亚',
                    'Sweden': '瑞典',
                    'Swaziland': '斯威士兰',
                    'Syria': '叙利亚',
                    'Chad': '乍得',
                    'Togo': '多哥',
                    'Thailand': '泰国',
                    'Tajikistan': '塔吉克斯坦',
                    'Turkmenistan': '土库曼斯坦',
                    'East Timor': '东帝汶',
                    'Trinidad and Tobago': '特里尼达和多巴哥',
                    'Tunisia': '突尼斯',
                    'Turkey': '土耳其',
                    'United Republic of Tanzania': '坦桑尼亚联合共和国',
                    'Uganda': '乌干达',
                    'Ukraine': '乌克兰',
                    'Uruguay': '乌拉圭',
                    'United States of America': '美国',
                    'Uzbekistan': '乌兹别克斯坦',
                    'Venezuela': '委内瑞拉',
                    'Vietnam': '越南',
                    'Vanuatu': '瓦努阿图',
                    'West Bank': '西岸',
                    'Yemen': '也门',
                    'South Africa': '南非',
                    'Zambia': '赞比亚',
                    'Zimbabwe': '津巴布韦'
                }

            },
            {
                name: '北京 Top10',
                type: 'map',
                mapType: '中俄',
                data: [],
                markLine: {
                    smooth: true,
                    effect: {
                        show: true,
                        scaleSize: 1,
                        period: 3,
                        color: '#fff',
                        shadowBlur: 10
                    },
                    itemStyle: {
                        normal: {
                            borderWidth: 1,
                            lineStyle: {
                                type: 'solid',
                                shadowBlur: 10
                            }
                        }
                    },
                    data: []
                },
                markPoint: {
                    symbol: 'emptyCircle',
                    symbolSize: function (v) {
                        //return 10 + v/10
                        return 10;
                    },
                    effect: {
                        show: true,
                        shadowBlur: 0
                    },
                    itemStyle: {
                        normal: {
                            label: {show: false}
                        },
                        emphasis: {
                            label: {position: 'top'}
                        }
                    },
                    data: []

                }
            }
        ]
    },
    loadMap:function(){
        var _this = this;
        var url = "";
        _this.loop++;
        if(_this.loop % 2 == 0){
            url = _this.urlItems.qtyTopURL;
            _this.option.title.text = "地区出口量（订单包裹数）";
        }else{
            url = _this.urlItems.amtTopURL;
            _this.option.title.text = "地区出口量（订单总金额）";
        }
        $.ajax({
            url: url,
            type: 'GET',
            dataType: 'json',
            cache: false,
            success: function (result) {
                result = result.result;
                if (result != null) {
                    if (null != result.min) {
                        _this.option.dataRange.min = result.min;
                    }
                    if (null != result.max) {
                        _this.option.dataRange.max = result.max;
                    }
                    if (null != result.geoCoord) {
                        _this.option.series[0].geoCoord = result.geoCoord;
                    }
                    if (result.topCityDataArray != null) {
                        _this.option.series[1].markPoint.data = result.topCityDataArray[0].markPointDataArr;
                        _this.option.series[1].name = result.topCityDataArray[0].cityName;
                        _this.option.series[1].markLine.data = result.topCityDataArray[0].markLineDataArr;
                    }
                    _this.successMap(_this.option);
                }
            },
            error: function(XMLHttpRequest, status, errorThrown){
                if(status=='timeout'){
                    $("#mapChart").html('请求超时');
                }else{
                    $("#mapChart").html('加载失败');
                }
            }

        });
    },
    successMap:function(option){
        var mapChart;
        require(
            [
                'echarts',
                'echarts/chart/map'
            ],
            function (ec) {
                if(option!=''){
                	mapChart = ec.init($('#mapChart')[0]);
                    mapChart.showLoading({text: '正在努力的读取数据中...'});
                    mapChart.setOption(option);
                    mapChart.showLoading();
                    mapChart.setOption(option, true);
                    mapChart.refresh();
                    mapChart.hideLoading();
                }
            }
        );
    },
    showGoodsChart1 : function(result){
		var myChart = echarts.init(document.getElementById('goodsChart1'));
        var option = {
        		backgroundColor: 'rgba(128, 128, 128, 0)', //#1a283f
        	    /*title : {
        	        text: 'top10品类销售金额(USD)',
        	        x:'center',
        	        padding : 55
        	    },*/
        	    tooltip : {
        	        trigger: 'item',
        	        formatter: "{a} <br/>{b} : {c} ({d}%)"
        	    },
        	    legend: {
        	        orient : 'vertical',
        	        align:'left',
        	        zindex : -1,
        	        x: 'right',
        	        data:[]
        	    },
        	    calculable : true,
        	    series : [
        	        {
        	            name:'品类销售金额(USD)',
        	            type:'pie',
        	            radius: ['50%', '70%'],
        	            center: ['40%', '50%'],
        	            label: {
        	                normal: {
        	                    show: false,
        	                    position: 'center'
        	                },
        	                emphasis: {
        	                    show: true,
        	                    textStyle: {
        	                        fontSize: '20',
        	                        fontWeight: 'bold'
        	                    }
        	                }
        	            },
        	            labelLine: {
        	                normal: {
        	                    show: false
        	                }
        	            }
        	        }
        	    ]
        	};
        for(var i = 0; i < result.length; i++){
        	result[i].name="NO"+(i+1)+":"+result[i].name;
            option.legend.data.push(result[i].name);
        }
        option.series[0].data=result;
        myChart.setOption(option);
	},
    GoodsChart1 : function(){
        _this = this;
        $.ajax({
            url:_this.urlItems.queryAmtTop,
            data:$("#searchForm").serialize(),
            type:'get',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.isSuccess){
                    var result = data.result;
                    if(result.length==0){
                    	result = [ {
                    	    "name" : "电子及家电类",
                    	    "value" : 3318.36
                    	  }, {
                    	    "name" : "五金工具类",
                    	    "value" : 1099.15
                    	  }, {
                    	    "name" : "车辆及配件类",
                    	    "value" : 418.0
                    	  } ];
                    }
                    _this.showGoodsChart1(result);
                }
            },
            error : function() {
                window.webDialogUtil.alert("提示","操作失败");
            }
        });
    },
	showGoodsChart2 : function(result){
		var myChart = echarts.init(document.getElementById('goodsChart2'));
        var option = {
        	    backgroundColor: 'rgba(128, 128, 128, 0)', //#1a283f
        	   /* title : {
        	        text: 'top10商品出口',
        	        x:'center',
        	        padding : 55
        	    },*/
        	    tooltip : {
        	        trigger: 'item',
        	        formatter: "{a} <br/>{b} : {c} ({d}%)"
        	    },
        	    legend: {
        	        orient : 'vertical',
        	        align:'left',
        	        zindex : -1,
        	        x: 'right',
        	        data:[]
        	    },
        	    calculable : true,
        	    series : [
        	        {
        	            name:'商品出口量',
        	            type:'pie',
        	            radius: ['50%', '70%'],
        	            center: ['40%', '50%'],
        	            label: {
        	                normal: {
        	                    show: false,
        	                    position: 'center'
        	                },
        	                emphasis: {
        	                    show: true,
        	                    textStyle: {
        	                        fontSize: '20',
        	                        fontWeight: 'bold'
        	                    }
        	                }
        	            },
        	            labelLine: {
        	                normal: {
        	                    show: false
        	                }
        	            }
        	        }
        	    ]
        	};
        for(var i = 0; i < result.length; i++){
        	result[i].name="NO"+(i+1)+":"+result[i].name;
            option.legend.data.push(result[i].name);
        }
        option.series[0].data=result;
        myChart.setOption(option);
	},
    GoodsChart2 : function(){
        _this = this;
        $.ajax({
            url:_this.urlItems.queryQtyTop,
            data:$("#searchForm").serialize(),
            type:'get',
            cache:false,
            dataType:'json',
            success:function(data) {
                if(data.isSuccess){
                    var result = data.result;
                    if(result.length==0){
                    	result = [ {
                    	    "name" : "电子及家电类",
                    	    "value" : 1157.0
                    	  }, {
                    	    "name" : "五金工具类",
                    	    "value" : 127.0
                    	  }, {
                    	    "name" : "车辆及配件类",
                    	    "value" : 30.0
                    	  } ];
                    }
                    _this.showGoodsChart2(result);
                }
            },
            error : function() {
                window.webDialogUtil.alert("提示","操作失败");
            }
        });
    },
}

$(function(){
	require.config({
	        paths: {
	            echarts: remoteRes+"/plugins/echarts"
	        }
	});
	statisticCtrl.statistic.GoodsChart1();
	statisticCtrl.statistic.GoodsChart2();
	statisticCtrl.statistic.bindEvent();
	statisticCtrl.statistic.loadStatisticChartInfo();
	statisticCtrl.statistic.loadStatisticInfo();
});